<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<title>用户日志</title>
		<link type="text/css" rel="stylesheet" href="../<s:property value="#session.themeStyle.mainCss" default="Skin/PM/LightBlue/main.css"/>" />
		<script type="text/javascript" src="<%=basePath%>js/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath%>js/store.js"></script>
		<script type="text/javascript" src="<%=basePath%>js/My97DatePicker/WdatePicker.js"></script>
		<script type="text/javascript">
$(document).ready(function() {
	$("#selectMaxPage").val($("#rowsPage").val());
	$("#selectNowpage").val($("#page").val());
	if($("#userName").val()==""){
		$("#userName").val("请输入查询内容");
	}
	if($("#beginTime").val()==""){
		$("#beginTime").val("请选择日期");
	}
	if($("#endTime").val()==""){
		$("#endTime").val("请选择日期");
	}
	var height = window.parent.document.getElementById("mainFrame").height-$("#tableTop").height()-46;
});
/* 改变每页显示条数时，需要自动跳转到第一页 */
function modPageSize(obj) {
	var size = $(obj).val();
	$("#rowsPage").val(size);
	getData();
}

/* 翻页时同时修改select控件页面数 */
function upDown(n) {
	$("#page").val(n);
	getData();
}
function changePageNum(obj) {
	var page = $(obj).val();
	$("#page").val(page);
	getData();
}
		function getData(){
			var page = $.trim($("#page").val());
			var rowsPage = $.trim($("#rowsPage").val());
			var beginTime = $.trim($("#beginTime").val());
			var endTime =$.trim($("#endTime").val());
			var userName =$.trim($("#userName").val());
			var fromFile = createFrom("logInfo-manage.action");
			if (beginTime=="请选择日期"){
					beginTime=""
			}
			if (endTime=="请选择日期"){
					endTime=""
			}
			if (userName=="请输入查询内容"){
					userName=""
			}
			if(page!=""){
				loadFrom("page",page,fromFile);	
			}
			if(rowsPage!=""){
				loadFrom("rowsPage",rowsPage,fromFile);	
			}
			if(beginTime!=""){
				loadFrom("beginTime",beginTime,fromFile);
			}
			if(endTime!=""){
				endTime = endTime +" 23:59:59";
				loadFrom("endTime",endTime,fromFile)
			}
			if(userName!=""){
				loadFrom("userName",userName,fromFile);
			}
			fromFile.submit();
		}
		function changeBegin(cs_id,value){ 
			var str_text = document.getElementById(cs_id);
				if (str_text.value==""){
					str_text.value=value
				}
		}
		function changeEnd(cs_id,value){ 
			var str_text = document.getElementById(cs_id);
				if (str_text.value==value){
					str_text.value=""
				}
		}
		</script>
		<style type="text/css">
<%--		css样式--%>
</style>
	</head>
	<body >
		<div style="margin-left: 8px;margin-right: 8px;border-bottom: 2px #3497cf solid;height: 24px;margin-top: 0px;line-height: 24px;">
				当前位置：系统管理&nbsp;&gt;&gt;&nbsp;日志管理
	    </div>
		<input type="hidden" id="rowsPage" value='<s:property value="rowsPage"/>' />
		<input type="hidden" id="page" value='<s:property value="page"/>' />
		<div id="tableTop" class="query" style="height: 95px;">
			<ul>
				<li class="title">
					查询条件
				</li>
			</ul>
			<div>
			<div class="queryOne">
					<label>
						用户名称
					</label>
					<input class="inputText" name="userName" id="userName" type="text" value="${userName }" style="color: #5F9EA0;font-style: italic; "   onblur="changeBegin(this.id,'请输入查询内容')" onfocus="changeEnd(this.id,'请输入查询内容')"/>
				</div>
				<div class="queryOne">
					<label>
						开始时间
					</label>
					<input class="inputText" onfocus="WdatePicker()" name="beginTime" id="beginTime" type="text" value="${beginTime }" style="color: #5F9EA0;font-style: italic; " onClick="WdatePicker()" onfocus="changeEnd(this.id,'请选择日期')" />
				</div>
				<div class="queryOne">
					<label>
						结束时间
					</label>
					<input class="inputText" onfocus="WdatePicker()" name="endTime" id="endTime" type="text" value="${endTime }" style="color: #5F9EA0;font-style: italic; " onClick="WdatePicker()" onfocus="changeEnd(this.id,'请选择日期')" />
				</div>
				<div class="queryOne" style="width: 100px">
					<a class="but28" onclick="getData()" style="text-decoration: none;">查询</a>
				</div>				
			</div>
		</div>
		<div class="tabBlock">
			<div class="dataGrid">
				<table id="divTable" style="overflow-y: auto;">
					<tr>
						<th nowrap="nowrap">
							用户[IP]
						</th>
						<th nowrap="nowrap">
							记录时间
						</th>
						<th nowrap="nowrap">
							结果
						</th>
					</tr>
					<s:iterator value="#attr.logList" status="status">
						<tr class="trStyle">
							<td style="width: 20%">
								<s:property value="userName" />
								&nbsp;
							</td>
							<td style="width: 20%">
								<s:date name="createDate" format="yyyy-MM-dd HH:mm:ss" />
								&nbsp;
							</td>
							<td style="width: 60%">
								<s:property value="remark" />
								&nbsp;
							</td>
						</tr>
					</s:iterator>
					<tr class="trBotton">
						<td colspan="4">
							<s:if test="count > 10">
							页数：<s:property value="page" />/<s:property value="allPages" /> ｜
							总数：<s:property value="count" /> ｜ 当前页：
							<select id="selectNowpage" style="width: 40px" name="page" onChange="changePageNum(this)">
									<s:bean name="org.apache.struts2.util.Counter" id="counter">
										<s:param name="first" value="1" />
										<s:param name="last" value="allPages" />
										<s:iterator>
											<option value="<s:property/>" ${page==i?"selected" : ""}>
												<s:property />
											</option>
										</s:iterator>
									</s:bean>
								</select>
							｜ 每页数：
							<select id="selectMaxPage" style="width: 50px" name="rowsPage" onChange="modPageSize(this)">
									<option value="10">
										10
									</option>
									<option value="20">
										20
									</option>
									<option value="50">
										50
									</option>
									<option value="100">
										100
									</option>
								</select>
								<s:if test="page > 1">
									<a href="javascript:upDown(1)">&lt;&lt;</a>
									<a href="javascript:upDown(${page - 1})">上页</a>
								</s:if>
								<s:if test="page < allPages">
									<a href="javascript:upDown(${page+1})">下页</a>
									<a href="javascript:upDown(${allPages})">&gt;&gt;</a>
								</s:if>
							</s:if>
						</td>
					</tr>
				</table>
			</div>
		</div>
	</body>
</html>